package pocketlog

import (
	"fmt"
	"io"
	"os"
)

// Logger is used to log information
type Logger struct {
	threshold Level
	output io.Writer
}

// 日志 Debug 模式
func (l *Logger) Debugf(format string, args...any) {
	if l.threshold > LevelDebug {
		return
	}
	l.logf(format, args...)
}
// 日志 Info 模式
func (l *Logger) Infof(format string, args ...any) {
	
}

func (l *Logger) Errorf(format string, args ...any) {
	
}

func (l *Logger) Logf(lvl Level, format string, args ...any) {
	if l.threshold > lvl {
		return
	}
	l.logf(format, args...)
}
// logf print the message to the output 
func (l *Logger) logf(format string, args ...any) {
	_,_ = fmt.Fprintf(l.output, format + "\n", args...)
}
// 创建一个Logger实例
func New(threshold Level, opts ...Option) *Logger {
	lgr := &Logger{threshold: threshold, output: os.Stdout}

	for _, configFunc := range opts {
		configFunc(lgr)		
	}
	return lgr
}
